define("WxCore", [], function() {
    let WxCore=function () {
        this.name="wuxie-core";
        this.version="1.0.0.RELEASE";
    }

    //本地存储
    WxCore.prototype.setLocalStoreItem=function(k,v){
        localStorage.setItem(k,JSON.stringify(v));
    }
    WxCore.prototype.getLocalStoreItem=function(k){
        let val=localStorage.getItem(k);
        if(val && val != '' && val != 'undefined'){
            return JSON.parse(val);
        }
        return val;
    }
    WxCore.prototype.removeLocalStoreItem=function(k){
        localStorage.removeItem(k);
    }

    //会话存储
    WxCore.prototype.setSessionStoreItem=function(k,v){
        sessionStorage.setItem(k,JSON.stringify(v));
    }
    WxCore.prototype.getSessionStoreItem=function(k){
        let val=sessionStorage.getItem(k);
        if(val && val != '' && val != 'undefined'){
            return JSON.parse(val);
        }
        return val;
    }
    WxCore.prototype.removeSessionStoreItem=function(k){
        sessionStorage.removeItem(k);
    }

    //数组工具集
    //得到两个数组的并集, 两个数组的元素为数值或字符串
    WxCore.prototype.arrayUnion=function (arr1, arr2) {
        return Array.from(new Set([...arr1, ...arr2]));
    }
    // 将对象中的数字属性转换为字符串
    WxCore.prototype.propertieToString=function (oldObject) {
        let newObject = {}
        for (let key in oldObject) {
            if (typeof oldObject[key] === 'number') {
                newObject[key] = oldObject[key] + ''
            } else {
                newObject[key] = oldObject[key]
            }
        }
        return newObject
    }

    // 时间转字符串
    WxCore.prototype.dateToString=function (dateValue) {
        if (dateValue instanceof Date) {
            let ardate = [dateValue.getFullYear(), dateValue.getMonth() + 1, dateValue.getDate(), dateValue.getHours(), dateValue.getMinutes(), dateValue.getSeconds()]
            for (let i = 0; i < ardate.length; i++) {
                ardate[i] = ardate[i] < 10 ? '0' + ardate[i].toString() : ardate[i]
            }
            return ardate.slice(0, 3).join('-') + ' ' + ardate.slice(3).join(':')
        } else {
            return ''
        }
    }

  return new WxCore();
}),
  //动态加载组件
  define("resolveComponent", [], function() {
    var resolve = async function(dependency) {
      var _result = await new Promise(function(resolve, reject) {
        require([dependency], function(val) {
          resolve(val);
        });
      });
      return _result;
    };
    return resolve;
  });
